// Author: Bjorn Schobben

#include "Vector.h"

Vector::Vector(): x(0), y(0)
{
}

Vector::Vector(const Scalar& initx, const Scalar& inity): x(initx), y(inity)
{
}

Vector::Vector(const Vector& rhs): x(rhs.x), y(rhs.y)
{
}

Vector::~Vector()
{
}

const Scalar& Vector::GetX() const
{
	return x;
}

const Scalar& Vector::GetY() const
{
	return y;
}

int Vector::GetIntX() const
{
	return x.GetInt();
}

int Vector::GetIntY() const
{
	return y.GetInt();
}

Vector Vector::GetNormal() const
{
	return Vector(y, -x);
}

void Vector::SetX(const Scalar& newx)
{
	x = newx;
}

void Vector::SetY(const Scalar& newy)
{
	y = newy;
}

void Vector::Rotate(const Scalar& radian)
{
	Scalar cosine = radian.CosineDegree();
	Scalar sine = radian.SineDegree();

	*this = Vector(x * cosine - y * sine, x * sine + y * cosine);
}

Vector& Vector::operator+=(const Vector& rhs)
{
	x += rhs.x;
	y += rhs.y;

	return *this;
}

Vector Vector::operator+(const Vector& rhs) const
{
	Vector result = *this;
	result += rhs;
	return result;
}

Vector& Vector::operator-=(const Vector& rhs)
{
	x -= rhs.x;
	y -= rhs.y;

	return *this;
}

Vector Vector::operator-(const Vector& rhs) const
{
	Vector result = *this;
	result -= rhs;
	return result;
}

Vector& Vector::operator*=(const Scalar& rhs)
{
	x *= rhs;
	y *= rhs;

	return *this;
}

Vector Vector::operator*(const Scalar& rhs) const
{
	Vector result = *this;
	result *= rhs;
	return result;
}

Vector& Vector::operator=(const Vector& rhs)
{
	x = rhs.x;
	y = rhs.y;

	return *this;
}

